#ifndef __OGREWIDGET_H__
#define __OGREWIDGET_H__

#include <Ogre.h>
//#include <QtOpenGL\QGLWidget>
#include <qgl.h>
#include <QMouseEvent>
#include <QTime>
#include <QLabel>

//#include <QX11Info>

class OgreWidget : public QGLWidget
{
  Q_OBJECT;
  
 public:
  OgreWidget( QWidget *parent=0 );

  ~OgreWidget();


protected:
	void init( std::string, std::string, std::string );	
	Ogre::RenderSystem* chooseRenderer( Ogre::RenderSystemList* );
	void resizeGL(int w, int h);
	void initializeGL();
	void paintGL();
	void createOgreWindow();
	void createSceneManagerAndCamera();
	void setupResources();
	void createScene();
	void paintAxis();
	virtual void setInitialCameraPosition();
	virtual void updateCamera();
	virtual void setUpAxis();


	// input functions
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *);
	void mouseMoveEvent(QMouseEvent *e);
	void wheelEvent(QWheelEvent *e);
	void keyPressEvent ( QKeyEvent * event );
 	
	

  

private:


	

	Ogre::Root *mOgreRoot;
	Ogre::RenderWindow *mOgreWindow;
	Ogre::Camera *mCamera;
	Ogre::Viewport *mViewport;
	Ogre::SceneManager *mSceneMgr;
	Ogre::SceneNode *mainNode;
	Ogre::SceneNode *lightNode;

	// user input and camera movement
	float cameraZoom, zoomFactor;
	Ogre::Vector2 mouseRotation;
	Ogre::Vector3 upAxis;
	QPoint mousePressPos;
	bool mousePressed;
	Qt::MouseButton buttonPressed;
	Ogre::Vector2 mousePos;

};

#endif